﻿<UserControl x:Class="AppCommerciaux.Views.CommandeEditView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:converters="clr-namespace:AppCommerciaux.converter"  
        Height="545" Width="1010">

    <UserControl.Resources>
        <converters:tiers_contactToStringValueConverter x:Key="tiers_contactToStringValueConverter" />
        <converters:tiers_societeToStringValueConverter x:Key="tiers_societeToStringValueConverter" />
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="60" />
            <RowDefinition Height="300" />
            <RowDefinition Height="50" />
            <RowDefinition Height="60" />
            <RowDefinition Height="60" />
            <RowDefinition Height="50" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition Width="300"/>
            <ColumnDefinition Width="300"/>
            <ColumnDefinition Width="300"/>
        </Grid.ColumnDefinitions>
        <TextBlock
            Grid.ColumnSpan="4"
            Text="{Binding Titre}" Margin="32,19,268,281" Grid.RowSpan="2"/>
        <DataGrid Name="dataGridCommande"
                  IsReadOnly="True"
                  SelectionMode="Single"
            Grid.Row="1"
                  Grid.Column="0"
                  Grid.ColumnSpan="3"
                  ItemsSource="{Binding ListLignesCommandes}"
                  SelectedItem="{Binding SelectedLigneCommande}" Margin="32,19,268,35"
               
                  >

            
            
        </DataGrid>
        <!--<ListView
            Grid.Row="1"
                  Grid.Column="1"
                  Grid.ColumnSpan="2"
                  ItemsSource="{Binding ListLignesCommandes}"
                  SelectedItem="{Binding SelectedLigneCommande}"/>-->



        <Label Content="date de création :" 
               Grid.Column="2" HorizontalAlignment="Left" Margin="54,22,0,0" Grid.Row="1" VerticalAlignment="Top"/>
        <TextBox x:Name="dateTextBox" 
                 Text="{Binding SelectedCommande.dateCreation}"
                 Grid.Column="2" HorizontalAlignment="Left" Grid.ColumnSpan="2" Height="23" Margin="182,25,0,0" Grid.Row="1" VerticalAlignment="Top" Width="250" IsReadOnly="True" />

        <Label Content="total HT :" 
               Grid.Column="2" HorizontalAlignment="Left" Margin="94,58,0,0" Grid.Row="1" VerticalAlignment="Top"/>
        <TextBox x:Name="totalHTTexbox" 
                 Grid.ColumnSpan="2" Grid.Column="2" HorizontalAlignment="Left" Height="23" Margin="183,62,0,0" Grid.Row="1" TextWrapping="Wrap" IsReadOnly="True"
                 Text="{Binding SelectedCommande.totalHT}" 
                 VerticalAlignment="Top" Width="249"/>



        <Label Content="total TTC :" 
               Grid.Column="2" HorizontalAlignment="Left" Margin="93,96,0,0" Grid.Row="1" VerticalAlignment="Top" RenderTransformOrigin="-0.209,-0.506"/>
        <TextBox x:Name="totalTTCTextBox" 
                 Text="{Binding SelectedCommande.totalTTC}"
                 Grid.Column="2" HorizontalAlignment="Left" Grid.ColumnSpan="2" Height="23" Margin="182,99,0,0" Grid.Row="1" TextWrapping="Wrap"  VerticalAlignment="Top" Width="250" IsReadOnly="True"/>


        <Label Content="synchro :" 
               Visibility="Hidden"
               Grid.Column="2" HorizontalAlignment="Left" Margin="100,221,0,0" Grid.Row="1" VerticalAlignment="Top"/>
        <TextBox x:Name="SynchroTextBox" 
                 Visibility="Hidden"
                 Text="{Binding SelectedCommande.synchro}"
                 Grid.Column="2" HorizontalAlignment="Left" Grid.ColumnSpan="2" Height="23" Margin="183,225,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="250" IsReadOnly="True" RenderTransformOrigin="0.704,0.739"/>


        <Label Content="client :" 
               Grid.Column="2" HorizontalAlignment="Left" Margin="113,142,0,0" Grid.Row="1" VerticalAlignment="Top"/>

        <ComboBox x:Name="clientCombobox"
                  IsEnabled="{Binding EnableCombobox}"
                  SelectedItem="{Binding SelectedCommande.tiers_contact, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                  
                  Grid.Column="2" HorizontalAlignment="Left" Margin="182,146,0,0" Grid.Row="1" VerticalAlignment="Top" Width="251" Grid.ColumnSpan="2"
        ItemsSource="{Binding ListClientView, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                  SelectionChanged="clientCombobox_SelectionChanged">



            <!--Converter={StaticResource tiers_contactToStringValueConverter}}"DisplayMemberPath="{Binding ListClient }"
                  ItemsSource="{Binding ListClient, Converter={StaticResource tiers_contactToStringValueConverter}, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"-->

            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Converter={StaticResource tiers_contactToStringValueConverter}}"/>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>


        <Label Content="contact :" 
               Grid.Column="2" HorizontalAlignment="Left" Margin="100,178,0,0" Grid.Row="1" VerticalAlignment="Top"/>

        <ComboBox x:Name="contactCombobox" 
                  IsEnabled="{Binding EnableCombobox}"
                  ItemsSource="{Binding ListSociete}"
                  SelectedItem="{Binding SelectedSociete, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                  Grid.Column="2" HorizontalAlignment="Left" Margin="182,182,0,0" Grid.Row="1" VerticalAlignment="Top" Width="251" Grid.ColumnSpan="2">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Converter={StaticResource tiers_societeToStringValueConverter}}"/>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>


        <Button x:Name="AjouterLigneCommandBouton" 
                Content="Ajouter  une ligne de commande" 
                Command="{Binding AjouterLigneCommand}"
                HorizontalAlignment="Left" Margin="64,270,0,0" Grid.Row="1" VerticalAlignment="Top" Width="195" Grid.ColumnSpan="2"/>

        <Button x:Name="SupprimerLigneCommandBouton" 
                Content="{Binding LabelboutonSupprimerLigneCommande}" 
                IsEnabled="{Binding EnableBoutonSupprimerLigneCommande}"
                Command="{Binding SupprimerLigneCommand}"
                HorizontalAlignment="Left" Margin="96,270,0,0" Grid.Row="1" VerticalAlignment="Top" Width="194" Grid.Column="1"/>


        <Button Content="{Binding LabelboutonValider}" 
                Grid.Column="2" HorizontalAlignment="Left" Height="23" Margin="0,35,0,0" Grid.Row="3" VerticalAlignment="Top" Width="91" Command="{Binding BoutonOk}"/>


        <Button Content="{Binding LabelboutonRetour}" 
                Grid.Column="2" HorizontalAlignment="Left" Height="23" Margin="114,35,0,0" Grid.Row="3" VerticalAlignment="Top" Width="102" Command="{Binding BoutonRetour}"/>
        <Label Content="{Binding LabelInformation}" HorizontalAlignment="Left" Margin="44,32,0,0" Grid.Row="2" VerticalAlignment="Top" Width="932" Grid.RowSpan="2" Grid.ColumnSpan="4"/>



    </Grid>
</UserControl>
